package com.doudoukeji.service.Bean;

import org.apache.commons.lang3.StringUtils;
import org.litepal.crud.DataSupport;

import java.io.Serializable;
import java.util.List;

public class HospitalLitapal extends DataSupport implements Serializable {


//	"id": "1",   //医院
//			"name": "青岛市立医院医院名称
//			"areaName": "市南区所在城市
//			"areaId": "0110" //地区

    private String cityid;
    private String name;
    private String areaName;
    private String areaId;
    private boolean isChoice = false;

    public boolean isChoice() {
        return isChoice;
    }

    public void setChoice(boolean isChoice) {
        this.isChoice = isChoice;
    }

    public String getCityid() {
        return cityid;
    }

    public void setCityid(String cityid) {
        this.cityid = cityid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public String getAreaId() {
        return areaId;
    }

    public void setAreaId(String areaId) {
        this.areaId = areaId;
    }

    public void setIsChoice(boolean isChoice) {
        this.isChoice = isChoice;
    }

    /**
     * 医院列表
     *
     * @return
     */
    public static List<HospitalLitapal> getHospitallitapalCity(String areaId) {
        List<HospitalLitapal> findAll = DataSupport.where("areaId = ?", areaId).find(HospitalLitapal.class);
        return findAll;

    }

    /**
     * 医院列表模糊查询
     *
     * @return
     */
    public static List<HospitalLitapal> getAllHospitallitapal(String name, String areaId) {
        List<HospitalLitapal> find = DataSupport.where("name like ? and areaId = ?", "%" + name + "%", areaId).find(HospitalLitapal.class);
        return find;

    }

    /**
     * 通过id遍历数据
     *
     * @param id
     * @return
     */
    public static HospitalLitapal getidHospitallitapal(String id) {
        List<HospitalLitapal> all = DataSupport.where(" cityid = ?", id).find(HospitalLitapal.class);
        if (all.size() > 0 && all != null) {
            return all.get(0);
        }
        return null;
    }

    /**
     * 通过医院ID 获取对应内容
     *
     * @param hospitals
     * @return
     */
    public static String getHospitalIdName(String hospitals) {
        String name = "";
        if (StringUtils.isNotBlank(hospitals)) {
            String[] ids = (hospitals + ",").split(",");
            for (int x = 0; x < ids.length; x++) {
                HospitalLitapal hospitalLitapal = HospitalLitapal.getidHospitallitapal(ids[x]);
                if (hospitalLitapal != null) {
                    name += hospitalLitapal.getName() + ",";
                }
            }
        }
        return name;
    }


}
